package com.dk.controller;

import com.dk.pojo.TabRouteVO;
import com.dk.service.CategoryService;
import com.dk.service.SellerService;
import com.dk.service.TravelRouteService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * 审核
 */
@Controller
@RequestMapping("auditController")
public class AuditController {
    @Autowired
    TravelRouteService travelRouteService;
    @Autowired
    CategoryService categoryService;
    @Autowired
    SellerService sellerService;

    @RequestMapping("getInfoNotReviewed")
    @ResponseBody
    public Map<String, Object> getInfoNotReviewed(TabRouteVO tabRoute,
                                       @RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
                                       @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        PageInfo<TabRouteVO> pageInfo = travelRouteService.getInfoNotReviewed(tabRoute,pageNumber,pageSize);
        Map<String, Object> map = new HashMap<>();
        map.put("total", pageInfo.getTotal());//总条数
        map.put("rows", pageInfo.getList());//数据
        return map;
    }

    @RequestMapping("pass/{id}")
    @ResponseBody
    public boolean UpdateToPass(@PathVariable("id")Integer id){
        int i = travelRouteService.updateToPass(id);
        return i>0;
    }
    @RequestMapping("turnDown/{id}")
    @ResponseBody
    public boolean UpdateToTurnDown(@PathVariable("id")Integer id){
        int i = travelRouteService.updateToTurnDown(id);
        return i>0;
    }
    @RequestMapping("reUpload/{id}")
    @ResponseBody
    public boolean reUpload(@PathVariable("id")Integer id){
        int i = travelRouteService.updateReUpload(id);
        return i>0;
    }

}
